
*---------------------------------------------------------------------------------------------------------------------------------------
* Setup
*---------------------------------------------------------------------------------------------------------------------------------------
clear all
set more off
version 14
program drop _all

* Confirm that the globals for the project root directory and the R 3.4.0 executable have been defined
assert !missing("$Wellness_WhatDoesWWDo")

* All required add-ons are stored in the /packages and /auxiliary folders
adopath ++ "$Wellness_WhatDoesWWDo/scripts/packages"
adopath ++ "$Wellness_WhatDoesWWDo/scripts/auxiliary"
mata: mata mlib index

* Program to replace text string from tex file
program define text_replace, nclass
	local tex_file `1'
	local from `2'
	local to `3'
	tempfile t
	filefilter "`tex_file'" "`t'", from("`from'") to("`to'") replace
	copy "`t'" "`tex_file'", replace
end

local texsave_settings "replace autonumber nofix"

*---------------------------------------------------------------------------------------------------------------------------------------
* Participation
* Screening, Fall Activity, and Spring Activity Completion, by groups A vs. {B, C}, and 25 vs. 75
*---------------------------------------------------------------------------------------------------------------------------------------
if 1 {

* Load screening and activity completion data
local year1_vars screening_c hra_c activity_f_c activity_s_c 
local year2_vars screening2017_c hra_c_yr2 activity_f_c_yr2 activity_s_c_yr2
use `year1_vars' `year2_vars' treat Strata using "$Wellness_WhatDoesWWDo/data/proc/wellness_analysis.dta", clear

* Keep those in treatment or control groups
keep if !missing(treat)
assert inlist(treat, 0, 1)
assert _N == 4834

* Replace each variable with non-missing values
foreach v in `year1_vars' `year2_vars' {
  * QC: 
	qui count if missing(`v')
  if "`v'" == "screening2017_c" {
    assert r(N) == 0
  }
  else if "`v'" == "hra_c_yr2" {
    assert r(N) == 15
  }
  else {
    assert r(N) == 1534
    assert missing(`v') == (treat == 0)
  }
  
  * Missing participation means didn't participate. Set to zero for 1st stage regression.
  rename `v' `v'_nomiss
  replace `v'_nomiss = 0 if missing(`v'_nomiss)
}


* Create tables of year1 and year2 participation effects
local tbl_settings "format(%11.3f) parentheses(stderr) asterisk(10 5 1)"

forvalues i = 1/2 {
  * local i 1
  tempfile first_stage_yr`i'
  
  local append replace
  foreach v in `year`i'_vars' {
    * local v activity_f_c
    noisily di "`v'"
    
    if strpos("`v'", "screening") local name screening
    if strpos("`v'", "hra") local name hra
    if strpos("`v'", "activity_f") local name activity_f
    if strpos("`v'", "activity_s") local name activity_s
    
    * Version A: No controls
    *   Calculate p-value of F-test
    *   Confirm that the standard error on the constant term is missing exactly when the estimated variance is negative
    qui _regress `v'_nomiss treat, robust
    local F = string(round(e(F), 0.1), "%11.1f")
    local prob_f = `=Ftail(e(df_m), e(df_r), e(F))'
    assert abs(`prob_f' - r(table)[4,1]) < 1.0e-16
    assert missing(_se[_cons]) == (e(V)[2,2] < 0)
    regsave using `first_stage_yr`i'', cmdline p addlabel(Strata, "No", F, "_`F'", prob_f, `prob_f') table(`name'_nocontrol,`tbl_settings') `append'
    
    local append append
    noisily di "`v'"
    
    * Version B: Strata FEs
    *   Calculate p-value of F-test
    *   Confirm that the standard error on the constant term is missing exactly when the estimated variance is negative
    qui regress `v'_nomiss treat, a(Strata) robust
    local F = string(round(e(F), 0.1), "%11.1f")
    local prob_f = `=Ftail(e(df_m), e(df_r), e(F))'
    assert abs(`prob_f' - r(table)[4,1]) < 1.0e-16
    assert missing(_se[_cons]) == (e(V)[2,2] < 0)
    regsave using `first_stage_yr`i'', cmdline p addlabel(Strata, "Yes", F, "_`F'", prob_f, `prob_f') table(`name'_strata,`tbl_settings') `append'
  }
}

* PANEL A: Year 1 participation
local year1_title "A. Year 1 participation"

* PANEL B: Year 1 participation
local year2_title "B. Year 2 participation"

* Create LaTeX table
use `first_stage_yr1', clear
append using `first_stage_yr2'
drop if var=="r2"
drop if var=="cmdline"
drop if var=="Strata"
drop if strpos(var, "_pval")
replace var = "" if strpos(var,"stderr")
* replace var = "Strata FEs" if var=="Strata"
replace var = "Treated" if var== "treat_coef"
replace var = "Constant" if var== "_cons_coef"
replace var = "\$N$" if var== "N"

* Format F-test p-values
foreach v in screening hra activity_f activity_s {
  foreach control in nocontrol strata {
    replace `v'_`control' = subinstr(`v'_`control', "_", "", 1) if var == "F"
    replace `v'_`control' = "\$<0.001$" if inlist(`v'_`control', "0", "0.000") & var == "prob_f"
  }
}
replace var = "\$F$" if var=="F"
replace var = "\$F$-test (\$p$-value)" if var=="prob_f"
list, sep(0)

ingap 1 8
replace var = "`year1_title'" in 1 if mi(var)
replace var = "`year2_title'" in 9 if mi(var)
list, sep(0)

* Export as LaTeX table
tempfile tex_table
local using using "`tex_table'"
local filename appendix_participation_table
local marker marker("tab:`filename'")
local title title("Wellness Program Participation Effects") 
local headerlines headerlines("\midrule\addlinespace[2.5ex] & \multicolumn{2}{c}{Screening} & \multicolumn{2}{c}{HRA} & \multicolumn{2}{c}{Fall Activity} & \multicolumn{2}{c}{Spring Activity}" "\cmidrule(lr){2-3} \cmidrule{4-5} \cmidrule(lr){6-7} \cmidrule{8-9}\addlinespace[-2.5ex]" "&{No Controls}&{Strata FEs}&{No Controls}&{Strata FEs}&{No Controls}&{Strata FEs}&{No Controls}&{Strata FEs}")
local fn footnote("Notes: This table reports treatment effects on completing components of the iThrive workplace wellness program tied to completion incentives. Only members of the treatment group were eligible to complete each component (i.e. control group participation is zero), except both groups were eligible for a follow-up screening in year 2. Each column in each panel reports estimates from a separate regression estimated over individuals in the treatment and control groups. The outcome in each regression is an indicator for completing the program component indicated by the column, and the primary independent variable is an indicator for inclusion in the treatment group. Participation effects for each outcome are estimated with and without baseline strata fixed effects. Robust standard errors are reported in parentheses. Missing standard errors are reported when the estimated variance is negative. A */**/*** indicates significance at the 10/5/1\% level using conventional inference.")
local size = "size(small)"
texsave `using', `texsave_settings' nonames `marker' hlines(1 5 8 9 13) bold("A. " "B. ") `title' `headerlines' landscape `fn' `size'

* Set panel titles to span all columns
text_replace "`tex_table'" "\BStabularnewline\W\BSmidrule\BSaddlinespace[1.5ex]" "\BStabularnewline\W\BSmidrule\BSaddlinespace[2.5ex]"
text_replace "`tex_table'" "\BStabularnewline\W\BSmidrule \BStextbf" "\BStabularnewline\W\BSmidrule\BSaddlinespace[2.5ex] \BStextbf"

copy `tex_table' "$Wellness_WhatDoesWWDo/results/tables/`filename'.tex", replace

}

*---------------------------------------------------------------------------------------------------------------------------------------
* Balance tables
*---------------------------------------------------------------------------------------------------------------------------------------

**************************************************************************************
* Prepare data and calculate some basic statistics
**************************************************************************************

tempfile descriptive_stats t

use "$Wellness_WhatDoesWWDo/data/proc/wellness_analysis.dta", clear
	
***
* Define variable sets for main analysis: strata vars, survey health vars, survey utilization vars, and claims vars
***

* Core variable sets (correspond to families used for multiple hypothesis testing)
local spending_var "spend_0715_0716"
local weighting_var "covg_0715_0716"

local strata_vars "male age50 age37_49 white salaryQ1 salaryQ2 salaryQ3 faculty AP"

local svy_hvars "everscreen active active_try cursmk othersmk formsmk drink drinkhvy chronic health1 health2 problems energy ehealth overweight badhealth sedentary"
local svy_uvars "druguse physician hospital"
local svy_prodvars "sickdays hrsworked50 jobsatisf1 jobsatisf2 mgmtsafety"

local claims_vars "`spending_var' spendOff_0715_0716 spendHosp_0715_0716 spendRx_0715_0716 nonzero_spend_0715_0716"

local admin_prodvars "sickleave_0815_0716 salary_0616"
local admin_hvars "marathon_2014_2016 gym_0815_0716"

* Aggregated sets (admin followed by survey)
local medical_spending "`claims_vars' `svy_uvars'"
local employment_productivity "`admin_prodvars' `svy_prodvars'"
local health_behaviors "`admin_hvars' `svy_hvars'"

* Define treat=999 to correspond to employees not in the study
replace treat = 999 if mi(treat)

preserve 

****************************************************************************************************************************************************************************
* Balance table: control vs treatment
****************************************************************************************************************************************************************************

* Store count of number of employees not in the study
count if treat==999
local num_nonparticipants = r(N)

count if treat==0
local Control_N = r(N)

count if treat==1
local Treatment_N = r(N)

***
* Calculate unweighted means of each var for each group, and test for equality across Control and treatment groups
***
local run_no = 1
qui foreach v in `strata_vars' `svy_hvars' `svy_uvars' `svy_prodvars' `claims_vars' `admin_prodvars' `admin_hvars' {

	* Sample size for the variable
	count if !mi(`v')
	local sample_size = `r(N)'
	
	count if mi(`v') & inlist(treat,0,1)
	local num_missing = r(N)

	* Calculate means for all groups (including those not in study)
	reg `v' ibn.treat, nocons robust
	
	* Test for equality across those enrolled in study
	test i0.treat==i1.treat
	local pval = `r(p)'
		
	* Round spending estimates to nearest dollar for better display in table
	regsave
	keep var coef
	if (strpos("`v'","spend") | "`v'"=="salary_0616") & !strpos("`v'","nonzero") replace coef = round(coef)
	
	gen outcome="`v'"
	replace var = subinstr(var,".treat","",.)
	reshape wide coef, i(outcome) j(var) string
	
	* Label results and save to a tempfile
	gen run_no = `run_no'
	gen pval = `pval'
	gen num_miss = `num_missing'
	gen sample_size = `sample_size'
	
	if `run_no'>1 append using `descriptive_stats'
	save `descriptive_stats', replace
	
	local run_no = `run_no'+1
	restore, preserve
}

******
* Joint balance tests: for each panel, are the regressors jointly predictive of enrollment into treatment/control groups? 
* Regress indicator on all panel variables. Do this simultaneously for all 7 groups using seemingly unrelated regression
******

* Joint tests are done only for those enrolled in the study
drop if treat==999

foreach panel in A B C D {

	     if "`panel'"=="A" local joint_test_vars "`strata_vars'"
	else if "`panel'"=="B" local joint_test_vars "`svy_hvars' `svy_uvars' `svy_prodvars'"
	else if "`panel'"=="C" local joint_test_vars "`claims_vars'"
	else if "`panel'"=="D" local joint_test_vars "`admin_prodvars' `admin_hvars'"
	else error 1
	
	reg treat `joint_test_vars', robust
	test `joint_test_vars'
	
	local joint_test_`panel' = string(`r(p)',"%5.3f")
	local sample_size_`panel' = e(N)
}


*******
* Format results from descriptive statistics and joint balance tests, and output the table
*******
use "`descriptive_stats'", clear
sort run_no
drop run_no

format coef* pval %5.3f
ren coef0bn   Control
ren coef1     Treatment
ren coef999   nonparticipants
order outcome nonparticipants Control


set obs `=_N+6'
replace outcome = "Sample size"                                     if _n==_N-4
replace outcome = "Joint balance test for panel A (\(p\)-value)"    if _n==_N-3
replace outcome = "Joint balance test for panel B (\(p\)-value)"    if _n==_N-2
replace outcome = "Joint balance test for panel C (\(p\)-value)"    if _n==_N-1
replace outcome = "Joint balance test for panel D (\(p\)-value)"    if _n==_N
foreach group in Control Treatment {
	replace `group' = ``group'_N'      if outcome=="Sample size"
}
replace nonparticipants = `num_nonparticipants' if outcome=="Sample size"
replace pval            = `joint_test_A'        if outcome=="Joint balance test for panel A (\(p\)-value)"
replace pval            = `joint_test_B'        if outcome=="Joint balance test for panel B (\(p\)-value)"
replace pval            = `joint_test_C'        if outcome=="Joint balance test for panel C (\(p\)-value)"
replace pval            = `joint_test_D'        if outcome=="Joint balance test for panel D (\(p\)-value)"

replace sample_size     = `sample_size_A'       if outcome=="Joint balance test for panel A (\(p\)-value)"
replace sample_size     = `sample_size_B'       if outcome=="Joint balance test for panel B (\(p\)-value)"
replace sample_size     = `sample_size_C'       if outcome=="Joint balance test for panel C (\(p\)-value)"
replace sample_size     = `sample_size_D'       if outcome=="Joint balance test for panel D (\(p\)-value)"

tostring nonparticipants-pval, format(%12.2fc) gen(tmp1 tmp2 tmp3 tmp4) force
tostring nonparticipants-pval, format(%12.3fc) replace force
local run_no=1
foreach v of varlist nonparticipants Control Treatment {
	replace `v' = subinstr(`v',".000","",.)
	replace `v' = tmp`run_no' if inlist(outcome,"gym_0815_0716","sickleave_0815_0716")
	local run_no = `run_no'+1
}
drop num_miss tmp*
tostring sample_size, format(%12.0gc) replace force

ingap 1 10 10 35 35 40 40
replace outcome = "A. Stratification Variables"                   in 1  if mi(outcome)
replace outcome = "B. 2016 Survey Variables"                      in 12 if mi(outcome)
* 2019-07-31: add en-dash
replace outcome = "C. Health Claims Variables (2015--2016)"        in 39 if mi(outcome)
replace outcome = "D. Health Behavior and Productivity Variables" in 46 if mi(outcome)

cleanvars outcome
replace outcome = subinstr(outcome," [admin]","",1)
replace outcome = subinstr(outcome," [survey]","",1)
replace outcome = "\ \ \ \ " + outcome if strpos(outcome,"Drug s") | strpos(outcome,"Office s") | strpos(outcome,"Hospital s") | strpos(outcome,"Other s")

label var outcome ""
label var nonparticipants "Not in Study"
label var pval "\(p\)-value"
label var sample_size "Sample Size"
foreach v of varlist Control Treatment {
	label var `v' `v'
}
foreach v of varlist * {
	replace `v' = "" if `v'=="."
}

* First balance table: Panels A and B, second table: Panels C, and D
gen table1 = inrange(_n,1,38) | inrange(_n,52,54)
gen table2 = !table1 | strpos(outcome,"Sample size")

local fn `"Notes: Columns (1)--(3) report unweighted means for different, nonoverlapping subsets of university employees. Column (4) reports the \(p\)-value from a joint test of equality of the two coefficients reported in columns (2)--(3). The joint balance test row reports the \(p\)-value from jointly testing whether the variables in a particular panel predict enrollment into treatment."'
texsave outcome-sample_size using "`t'" if table1, `texsave_settings' hlines(1 12 -3) bold("A. " "B. " ) title("Means of Study Variables at Baseline") varlabels headerlines("\midrule & & \multicolumn{3}{c}{Enrolled in Study} &" "\cmidrule(lr){3-5}") size(scriptsize) footnote(`"`fn'"', size(scriptsize)) marker(tab:balance_tests1) landscape geometry("left=.2in,right=.2in")
filefilter "`t'" "$Wellness_WhatDoesWWDo/results/tables/balance_tests1.tex", from("\BScmidrule(lr){3-5} \BStabularnewline") to("\BScmidrule(lr){3-5}") replace

* Second table: Panels C and D
texsave outcome-sample_size using "`t'" if table2, `texsave_settings' hlines(1 -8 -3) bold("C. " "D. ") title("Means of Study Variables at Baseline, Continued") varlabels headerlines("\midrule & & \multicolumn{3}{c}{Enrolled in Study} &" "\cmidrule(lr){3-5}") size(scriptsize) footnote(`"`fn'"', size(scriptsize)) marker(tab:balance_tests2) landscape geometry("left=.2in,right=.2in")
filefilter "`t'" "$Wellness_WhatDoesWWDo/results/tables/balance_tests2.tex", from("\BScmidrule(lr){3-5} \BStabularnewline") to("\BScmidrule(lr){3-5}") replace

restore, preserve

****************************************************************************************************************************************************************************
* Full balance table - for appendix only
****************************************************************************************************************************************************************************

* Store count of number of employees not in the study
count if StudyArm=="Not Randomized":StudyArm
local num_nonparticipants = r(N)

***
* Calculate unweighted means of each var for each group, and test for equality across Control-C75 groups
***
local run_no = 1
qui foreach v in `strata_vars' `svy_hvars' `svy_uvars' `svy_prodvars' `claims_vars' `admin_prodvars' `admin_hvars' {

	* Sample size for the variable
	count if !mi(`v')
	local sample_size = `r(N)'
	
	count if mi(`v') & StudyArm!="Not Randomized":StudyArm
	local num_missing = r(N)

	* Calculate means for all groups (including those not in study)
	reg `v' ibn.StudyArm, nocons robust
	
	* Test for equality across those enrolled in study
	test i1.StudyArm==i2.StudyArm==i3.StudyArm==i4.StudyArm==i5.StudyArm==i6.StudyArm==i7.StudyArm
	local pval = `r(p)'
		
	* Round spending estimates to nearest dollar for better display in table
	regsave
	keep var coef
	if (strpos("`v'","spend") | "`v'"=="salary_0616") & !strpos("`v'","nonzero") replace coef = round(coef)
	
	gen outcome="`v'"
	replace var = subinstr(var,".StudyArm","",.)
	reshape wide coef, i(outcome) j(var) string
	
	* Label results and save to a tempfile
	gen run_no = `run_no'
	gen pval = `pval'
	gen num_miss = `num_missing'
	gen sample_size = `sample_size'
	
	if `run_no'>1 append using `descriptive_stats'
	save `descriptive_stats', replace
	
	local run_no = `run_no'+1
	restore, preserve
}

******
* Joint balance tests: for each panel, are the regressors jointly predictive of enrollment into treatment/control groups? 
* Regress indicator on all panel variables. Do this simultaneously for all 7 groups using seemingly unrelated regression
******

* Joint tests are done only for those enrolled in the study
drop if StudyArm=="Not Randomized":StudyArm

* Generate indicator variable foreach control/treatment group
foreach group in Control A25 A75 B25 B75 C25 C75 {
	gen `group' = StudyArm=="`group'":StudyArm
	count if `group'==1
	local `group'_N = r(N)
}

foreach panel in A B C D {

	     if "`panel'"=="A" local joint_test_vars "`strata_vars'"
	else if "`panel'"=="B" local joint_test_vars "`svy_hvars' `svy_uvars' `svy_prodvars'"
	else if "`panel'"=="C" local joint_test_vars "`claims_vars'"
	else if "`panel'"=="D" local joint_test_vars "`admin_prodvars' `admin_hvars'"
	else error 1
	
	local test_cmdline "0"
	qui foreach group in Control A25 A75 B25 B75 C25 C75 {
		reg `group' `joint_test_vars'
		estimates store m_`group'
	
		foreach v in `joint_test_vars' {
			local test_cmdline "`test_cmdline' == [m_`group'_mean]`v'"
		}
	}
	suest m_Control m_A25 m_A75 m_B25 m_B75 m_C25 m_C75, vce(robust)
	test `test_cmdline'
	local joint_test_`panel' = string(`r(p)',"%5.3f")
	local sample_size_`panel' = e(N)
}


*******
* Format results from descriptive statistics and joint balance tests, and output the table
*******
use "`descriptive_stats'", clear
sort run_no
drop run_no

format coef* pval %5.3f
ren coef1bn A25
ren coef2   A75
ren coef3   B25
ren coef4   B75
ren coef5   C25
ren coef6   C75
ren coef7   Control
ren coef8   nonparticipants
order outcome nonparticipants Control

set obs `=_N+6'
replace outcome = "Sample size"                                     if _n==_N-4
replace outcome = "Joint balance test for panel A (\(p\)-value)"    if _n==_N-3
replace outcome = "Joint balance test for panel B (\(p\)-value)"    if _n==_N-2
replace outcome = "Joint balance test for panel C (\(p\)-value)"    if _n==_N-1
replace outcome = "Joint balance test for panel D (\(p\)-value)"    if _n==_N
foreach group in Control A25 A75 B25 B75 C25 C75 {
	replace `group' = ``group'_N'      if outcome=="Sample size"
}
replace nonparticipants = `num_nonparticipants' if outcome=="Sample size"
replace pval            = `joint_test_A'        if outcome=="Joint balance test for panel A (\(p\)-value)"
replace pval            = `joint_test_B'        if outcome=="Joint balance test for panel B (\(p\)-value)"
replace pval            = `joint_test_C'        if outcome=="Joint balance test for panel C (\(p\)-value)"
replace pval            = `joint_test_D'        if outcome=="Joint balance test for panel D (\(p\)-value)"

replace sample_size     = `sample_size_A'       if outcome=="Joint balance test for panel A (\(p\)-value)"
replace sample_size     = `sample_size_B'       if outcome=="Joint balance test for panel B (\(p\)-value)"
replace sample_size     = `sample_size_C'       if outcome=="Joint balance test for panel C (\(p\)-value)"
replace sample_size     = `sample_size_D'       if outcome=="Joint balance test for panel D (\(p\)-value)"

tostring nonparticipants-pval, format(%12.2fc) gen(tmp1 tmp2 tmp3 tmp4 tmp5 tmp6 tmp7 tmp8 tmp9) force
tostring nonparticipants-pval, format(%12.3fc) replace force
local run_no=1
foreach v of varlist nonparticipants Control A25 A75 B25 B75 C25 C75 {
	replace `v' = subinstr(`v',".000","",.)
	replace `v' = tmp`run_no' if inlist(outcome,"gym_0815_0716","sickleave_0815_0716")
	local run_no = `run_no'+1
}
drop num_miss tmp*
tostring sample_size, format(%12.0gc) replace force

ingap 1 10 10 35 35 40 40
replace outcome = "A. Stratification Variables"                   in 1  if mi(outcome)
replace outcome = "B. 2016 Survey Variables"                      in 12 if mi(outcome)
* 2019-07-31: add en-dash
replace outcome = "C. Health Claims Variables (2015--2016)"       in 39 if mi(outcome)
replace outcome = "D. Health Behavior and Productivity Variables" in 46 if mi(outcome)

cleanvars outcome
replace outcome = subinstr(outcome," [admin]","",1)
replace outcome = subinstr(outcome," [survey]","",1)
replace outcome = "\ \ \ \ " + outcome if strpos(outcome,"Drug s") | strpos(outcome,"Office s") | strpos(outcome,"Hospital s") | strpos(outcome,"Other s")

label var outcome ""
label var nonparticipants "Not in Study"
label var pval "\(p\)-value"
label var sample_size "Sample size"
foreach v of varlist Control-C75 {
	label var `v' `v'
}
foreach v of varlist * {
	replace `v' = "" if `v'=="."
}

* First balance table: Panels A and B, second table: Panels C, and D
gen table1 = inrange(_n,1,38) | inrange(_n,52,54)
gen table2 = !table1 | strpos(outcome,"Sample size")

local fn `"Notes: Columns (1)--(8) report unweighted means for different, nonoverlapping subsets of university employees. Column (9) reports the \(p\)-value from a joint test of equality of the seven coefficients reported in columns (2)--(8). We also estimate a seemingly unrelated regression model to test whether the variables listed in a particular panel predict enrollment into any of the seven control or treatment groups.  The joint balance test row reports the \(p\)-value from jointly testing whether all regression coefficients across all seven study groups are equal to 0."'
texsave outcome-sample_size using "`t'" if table1, `texsave_settings' hlines(1 12 -3) bold("A. " "B. " ) title("Means of Study Variables at Baseline For All Study Arms") varlabels headerlines("\midrule & & \multicolumn{8}{c}{Enrolled in Study} &" "\cmidrule(lr){3-10}") size(scriptsize) footnote(`"`fn'"', size(scriptsize)) marker(tab:apppendix_balance_tests1) landscape geometry("left=.2in,right=.2in")
filefilter "`t'" "$Wellness_WhatDoesWWDo/results/tables/appendix_balance_tests1.tex", from("\BScmidrule(lr){3-10} \BStabularnewline") to("\BScmidrule(lr){3-10}") replace

* Second table: Panels C and D
texsave outcome-sample_size using "`t'" if table2, `texsave_settings' hlines(1 -8 -3) bold("C. " "D. ") title("Means of Study Variables at Baseline For All Study Arms, Continued") varlabels headerlines("\midrule & & \multicolumn{8}{c}{Enrolled in Study} &" "\cmidrule(lr){3-10}") size(scriptsize) footnote(`"`fn'"', size(scriptsize)) marker(tab:apppendix_balance_tests2) landscape geometry("left=.2in,right=.2in")
filefilter "`t'" "$Wellness_WhatDoesWWDo/results/tables/appendix_balance_tests2.tex", from("\BScmidrule(lr){3-10} \BStabularnewline") to("\BScmidrule(lr){3-10}") replace

** EOF
